package com.tang.websocket.v1.test;

import com.tang.websocket.v1.handler.LoggingWebsocketHandlerDecorator;
import com.tang.websocket.v1.handler.WebSocketHandler;
import com.tang.websocket.v1.WebSocketLife;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.websocket.server.ServerEndpoint;

/**
 * @author Tang
 * @classname SimpleSocket
 * @description [  ]
 * @date 2022/11/29 11:31
 */
@Component
@ServerEndpoint(value = "/SimpleSocket/{id}")
public class SimpleSocket extends WebSocketLife {

    private static SimpleWebSocketHandler webSocketHandler;

    @Override
    public WebSocketHandler getWebSocketHandler() {
        return new LoggingWebsocketHandlerDecorator(webSocketHandler);
    }

    @Autowired
    public void setWebSocketHandler(SimpleWebSocketHandler webSocketHandler) {
        SimpleSocket.webSocketHandler = webSocketHandler;
    }
}
